package com.zhongkun.datahome.service.processor.dto;

import com.alibaba.excel.annotation.ExcelProperty;
import com.zhongkun.datahome.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.text.MessageFormat;
import java.util.List;

/**
 * @Author: lifengsheng
 * @Date: 2025/4/23 17:16
 * @Desc
 */
@Data
public class SkuDto {
    // 记录所在行号
    private int rowIndex;

    @NotNull(message = "【商品类目】不能为空")
    @Length(min = 2, max = 32, message = "【商品类目】长度应该在{min}到{max}之间")
    @ExcelProperty(index = 0)
    @ApiModelProperty("商品类目")
    @Excel(name = "类目名称")
    private String category;

    @NotNull(message = "【商品单位】不能为空")
    @Length(min = 1, max = 32, message = "【商品单位】长度应该在{min}到{max}之间")
    @ExcelProperty(index = 1)
    @ApiModelProperty("商品单位")
    @Excel(name = "单位")
    private String unit;

    @NotNull(message = "【商品名称】不能为空")
    @Length(min = 2, max = 64, message = "【商品名称】长度应该在{min}到{max}之间")
    @ExcelProperty(index = 2)
    @ApiModelProperty("商品名称")
    @Excel(name = "商品名称")
    private String skuName;

    @NotNull(message = "【品牌名称】不能为空")
    @Length(min = 1, max = 32, message = "【品牌名称】长度应该在{min}到{max}之间")
    @ExcelProperty(index = 3)
    @ApiModelProperty("品牌名称")
    @Excel(name = "品牌")
    private String brandName;


    // @NotNull(message = "【商品型号】不能为空")
    @Length(min = 0, max = 128, message = "【商品型号】长度应该在{min}到{max}之间")
    @ExcelProperty(index = 4)
    @ApiModelProperty("商品型号")
    @Excel(name = "型号")
    private String specification;

//    @ExcelProperty(index = 5)
//    @ApiModelProperty("商品图片")
//    @Excel(name = "图片", cellType = Excel.ColumnType.IMAGE)
//    private String skuPic;

    //@NotNull(message = "【备注】不能为空")
    @Length(max = 512, message = "【备注】长度不能超过{max}")
    @ExcelProperty(index = 6)
    @ApiModelProperty("备注")
    @Excel(name = "备注")
    private String remark;

    private List<String> urls;

    public String getKey(){
        return MessageFormat.format("{0}-{1}-{2}-{3}-{4}", this.getSkuName(), this.getCategory(), this.getUnit(), this.getBrandName(), this.getSpecification());
    }
}
